package com.hfuu.controller.user;

import com.hfuu.model.ResponseEntity;
import com.hfuu.model.ResponseEntityBuilder;
import com.hfuu.service.user.OrginzerService;
import com.hfuu.service.user.request.OrginzerRequest;
import com.hfuu.service.user.response.OrginzerResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.core.MediaType;
import java.util.List;

/**
 * Author: admin
 * Date: 2018/4/21
 * time: 上午10:23
 */
@Api(tags="组织管理")
@RestController
@RequestMapping("/api/orginzer")
public class OrginzerController {


    @Autowired
    private OrginzerService orginzerService;

    @ApiOperation("查询我的组织列表")
    @RequestMapping(value = "/listMyOrginzer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON)
    @ResponseBody
    public ResponseEntity<List<OrginzerResponse>> listMyOrgizer(@RequestBody OrginzerRequest request) throws Exception{
        return ResponseEntityBuilder.success(orginzerService.listMyOrgizer(request));
    }

    @ApiOperation("参加组织")
    @RequestMapping(value = "/joinOrginzer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON)
    @ResponseBody
    public ResponseEntity<Object> joinOrginzer(@RequestBody OrginzerRequest request) throws Exception{
        return ResponseEntityBuilder.success(orginzerService.joinOrginzer(request));
    }

    @ApiOperation("退出组织")
    @RequestMapping(value = "/outOrginzer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON)
    @ResponseBody
    public ResponseEntity<Object> outOrginzer(@RequestBody OrginzerRequest request) throws Exception{
        return ResponseEntityBuilder.success(orginzerService.outOrginzer(request));
    }

}
